﻿Namespace Geral

    Public Class Formulas

        Public Shared Function CalcularAbilityPowerFinal(ByVal Ability_Power As Decimal, _
                                                         ByVal Ability_Power_Level As Decimal, _
                                                         ByVal Ability_Power_Mod_Level As Decimal, _
                                                         ByVal Ability_Power_Mod_Flat As Decimal, _
                                                         ByVal Ability_Power_Mod_Perc As Decimal, _
                                                         ByVal Level As Short) As Decimal

            Return (((Ability_Power + ((Ability_Power_Level + Ability_Power_Mod_Level) * Level)) + Ability_Power_Mod_Flat) * (1 + (Ability_Power_Mod_Perc / 100)))

        End Function

        Public Shared Function CalcularArmorFinal(ByVal Armor_Base As Decimal, _
                                                  ByVal Armor_Base_Level As Decimal, _
                                                  ByVal Armor_Mod_Level_Flat As Decimal, _
                                                  ByVal Armor_Mod_Flat As Decimal, _
                                                  ByVal Armor_Mod_Perc As Decimal, _
                                                  ByVal Level As Short) As Decimal

            Return (((Armor_Base + ((Armor_Base_Level + Armor_Mod_Level_Flat) * Level)) + Armor_Mod_Flat) * (1 + (Armor_Mod_Perc / 100)))

        End Function

        Public Shared Function CalcularAttackDamage(ByVal Attack_Damage_Base As Decimal, _
                                                    ByVal Attack_Damage_Base_Level As Decimal, _
                                                    ByVal Attack_Damage_Mod_Level_Flat As Decimal, _
                                                    ByVal Attack_Damage_Mod_Flat As Decimal, _
                                                    ByVal Attack_Damage_Mod_Perc As Decimal, _
                                                    ByVal Level As Short) As Decimal

            Return (((Attack_Damage_Base + ((Attack_Damage_Base_Level + Attack_Damage_Mod_Level_Flat) * Level)) + Attack_Damage_Mod_Flat) * (1 + (Attack_Damage_Mod_Perc / 100)))

        End Function

        Public Shared Function CalcularAttackSpeedFinal(ByVal Attack_Speed_Base As Decimal, _
                                                        ByVal Attack_Speed_Base_Level As Decimal, _
                                                        ByVal Attack_Speed_Mod_Flat As Decimal, _
                                                        ByVal Level As Short) As Decimal

            Return (Attack_Speed_Base * (1 + (((Attack_Speed_Base_Level * (Level - 1)) + Attack_Speed_Mod_Flat) / 100)))

        End Function

        Public Shared Function CalcularHPFinal(ByVal HP_Base As Decimal, ByVal HP_Base_Level As Decimal, ByVal HP_Mod_Level_Flat As Decimal, _
                                               ByVal HP_Mod_Flat As Decimal, ByVal HP_Mod_Perc As Decimal, ByVal Level As Short) As Decimal

            Return (((HP_Base + ((HP_Base_Level + HP_Mod_Level_Flat) * Level)) + HP_Mod_Flat) * (1 + (HP_Mod_Perc / 100)))

        End Function

        Public Shared Function CalcularHPRegenFinal(ByVal HP_Regen_Base As Decimal, _
                                                    ByVal HP_Regen_Base_Level As Decimal, _
                                                    ByVal HP_Regen_Mod_Flat As Decimal, _
                                                    ByVal HP_Regen_Mod_Level_Flat As Decimal, _
                                                    ByVal HP_Regen_Mod_Perc As Decimal, _
                                                    ByVal Level As Short) As Decimal

            Return (((HP_Regen_Base + ((HP_Regen_Base_Level + HP_Regen_Mod_Level_Flat) * Level)) + HP_Regen_Mod_Flat) * (1 + (HP_Regen_Mod_Perc / 100)))

        End Function

        Public Shared Function CalcularMagicResistFinal(ByVal Magic_Resist_Base As Decimal, _
                                                        ByVal Magic_Resist_Base_Level As Decimal, _
                                                        ByVal Magic_Resist_Mod_Flat As Decimal, _
                                                        ByVal Magic_Resist_Mod_Perc As Decimal, _
                                                        ByVal Magic_Resist_Mod_Level_Flat As Decimal, _
                                                        ByVal Level As Short) As Decimal

            Return (((Magic_Resist_Base + ((Magic_Resist_Base_Level + Magic_Resist_Mod_Level_Flat) * Level)) + Magic_Resist_Mod_Flat) * (1 + (Magic_Resist_Mod_Perc / 100)))

        End Function

        Public Shared Function CalcularMovementSpeedFinal(ByVal Movement_Speed_Base As Decimal, _
                                                          ByVal Movement_Speed_Mod_Flat As Decimal, _
                                                          ByVal Movement_Speed_Mod_Perc As Decimal) As Decimal

            Dim MS_Raw As Decimal = (Movement_Speed_Base + Movement_Speed_Mod_Flat) * (1 + (Movement_Speed_Mod_Perc / 100))

            If (MS_Raw > 490) Then
                Return ((MS_Raw - 490) * 0.5) + 475
            ElseIf (MS_Raw > 415) Then
                Return ((MS_Raw - 415) * 0.8) + 415
            Else
                Return MS_Raw
            End If

        End Function

        Public Shared Function CalcularRecursoFinal(ByVal Recurso_Base As Decimal, _
                                                    ByVal Recurso_Base_Level As Decimal, _
                                                    ByVal Recurso_Mod_Flat As Decimal, _
                                                    ByVal Recurso_Mod_Perc As Decimal, _
                                                    ByVal Recurso_Mod_Level_Flat As Decimal, _
                                                    ByVal Level As Short) As Decimal

            Return (((Recurso_Base + ((Recurso_Base_Level + Recurso_Mod_Level_Flat) * Level)) + Recurso_Mod_Flat) * (1 + (Recurso_Mod_Perc / 100)))

        End Function

        Public Shared Function CalcularRecursoRegenFinal(ByVal Recurso_Regen_Base As Decimal, _
                                                         ByVal Recurso_Regen_Base_Level As Decimal, _
                                                         ByVal Recurso_Regen_Mod_Flat As Decimal, _
                                                         ByVal Recurso_Regen_Mod_Perc As Decimal, _
                                                         ByVal Recurso_Regen_Mod_Level_Flat As Decimal, _
                                                         ByVal Level As Short) As Decimal

            Return (((Recurso_Regen_Base + ((Recurso_Regen_Base_Level + Recurso_Regen_Mod_Level_Flat) * Level)) + Recurso_Regen_Mod_Flat) * (1 + (Recurso_Regen_Mod_Perc / 100)))

        End Function

        Public Shared Function CalcularReducaoDano(ByVal Armor_Final As Decimal) As Decimal

            Return 1 - (100 / (100 + Armor_Final))

        End Function

        Public Shared Function CalcularReducaoMagia(ByVal Magic_Resist_final As Decimal) As Decimal

            Return 1 - (100 / (100 + Magic_Resist_final))

        End Function

    End Class

End Namespace